<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">

<head>
<title>js第4课-01-函数传参</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="这是js第4课-01-函数传参">

<style>
#div1 {
	width: 200px;
	height: 200px;
	boarder: 1px solid black;
}

.box {
	background: red;
}
</style>

<script>
	function toRed() {
		var oDiv = document.getElementById("div1");
		// oDiv.style.background = "red";
		// alert(oDiv.style.background);
		oDiv.className = "box";
	}

	function toGreen() {
		var oDiv = document.getElementById("div1");
		oDiv.style.background = "green";
	}
</script>

</head>

<body>
	<input type="button" value="变红" onclick="toRed()">
	<input type="button" value="变绿" onclick="toGreen()">
	<!-- <div id="div1" style="background: red;"></div> -->
	<div id="div1"></div>
</body>

</html>